﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using Bitis_KeToanThue_Pro_DungChung.Common;
namespace Bitis_KeToanThue_Pro_QuanTri.AccessDatabase
{
   public class DanhMucPhongBan
    {
        AccessData ac = new AccessData(1);
        public int sua(string mapb, string phongban, string mapbmoi)
        {
            SqlParameter[] arrPara = new SqlParameter[3];
            arrPara[0] = new SqlParameter("@MaPB", SqlDbType.VarChar);
            arrPara[0].Value = mapb;
            arrPara[1] = new SqlParameter("@TenPB", SqlDbType.NVarChar);
            arrPara[1].Value = phongban;

            arrPara[2] = new SqlParameter("@MaPBMoi", SqlDbType.VarChar);
            arrPara[2].Value = mapbmoi;
            DataTable dt = ac.ftblDocDuLieuSP("danhmucphongBan_sua", arrPara);
            return int.Parse(dt.Rows[0]["ErrCode"].ToString());
        }
        public int xoa(string mapb)
        {
            SqlParameter[] arrPara = new SqlParameter[1];
            arrPara[0] = new SqlParameter("@MaPB", SqlDbType.VarChar);
            arrPara[0].Value = mapb;

            DataTable dt = ac.ftblDocDuLieuSP("danhmucphongBan_xoa", arrPara);
            return int.Parse(dt.Rows[0]["ErrCode"].ToString());
        }
        public int them(string mapb, string phongban)
        {
            SqlParameter[] arrPara = new SqlParameter[2];
            arrPara[0] = new SqlParameter("@MaPB", SqlDbType.VarChar);
            arrPara[0].Value = mapb;
            arrPara[1] = new SqlParameter("@TenPB", SqlDbType.NVarChar);
            arrPara[1].Value = phongban;

            DataTable dt = ac.ftblDocDuLieuSP("danhmucphongBan_them", arrPara);
            return int.Parse(dt.Rows[0]["ErrCode"].ToString());
        }


        public DataTable loadgird()
        {

            return ac.ftblDocDuLieuSP("danhmucphongBan_loaddulieu", null);
        }
    }
}
